package com.netease.pris.activity.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import com.netease.image.c;
import java.util.ArrayList;
import java.util.Iterator;

public class f
  implements View.OnClickListener
{
  private PopupWindow a;
  private Context b;
  private ArrayList c = new ArrayList();
  private bz d;
  private LayoutInflater e;
  private Handler f = null;

  public f(Context paramContext)
  {
    this.b = paramContext;
    this.e = LayoutInflater.from(paramContext);
    this.f = new Handler();
  }

  private int a(View paramView1, PopupWindow paramPopupWindow, View paramView2, int paramInt1, int paramInt2)
  {
    paramView2.measure(View.MeasureSpec.makeMeasureSpec(paramInt1, -2147483648), View.MeasureSpec.makeMeasureSpec(paramPopupWindow.getMaxAvailableHeight(paramView1), -2147483648));
    return paramView2.getMeasuredHeight();
  }

  public void a()
  {
    this.c.clear();
  }

  public void a(int paramInt1, int paramInt2)
  {
    if (paramInt2 == 0);
    a(paramInt1, this.b.getResources().getString(paramInt2));
  }

  public void a(int paramInt, String paramString)
  {
    as localas = new as(this, paramInt, paramString);
    this.c.add(localas);
  }

  public void a(View paramView, int paramInt1, int paramInt2, int paramInt3)
  {
    b();
    View localView = this.e.inflate(2130903059, null, false);
    ViewGroup localViewGroup = (ViewGroup)localView.findViewById(2131558454);
    Iterator localIterator = this.c.iterator();
    int i = this.c.size();
    int j = 0;
    if (localIterator.hasNext())
    {
      as localas = (as)localIterator.next();
      Button localButton = (Button)this.e.inflate(2130903123, localViewGroup, false);
      localButton.setText(localas.b);
      localButton.setTag(localas);
      int i4 = 2130837767;
      if (j == 0)
      {
        i4 = 2130837766;
        if (i == 1)
          i4 = 2130837768;
      }
      while (true)
      {
        localButton.setBackgroundResource(i4);
        localButton.setOnClickListener(this);
        localViewGroup.addView(localButton);
        j++;
        break;
        if (j != i - 1)
          continue;
        i4 = 2130837765;
      }
    }
    this.a = new PopupWindow(localView, -2, -2);
    this.a.setBackgroundDrawable(new BitmapDrawable());
    this.a.setTouchable(true);
    this.a.setFocusable(true);
    this.a.setInputMethodMode(2);
    this.a.setOutsideTouchable(true);
    int k = paramView.getMeasuredWidth();
    int m = a(paramView, this.a, localView, k, 0);
    int n = localView.getMeasuredWidth();
    int i1 = c.a(this.b, 0.0F);
    Rect localRect = new Rect();
    paramView.getWindowVisibleDisplayFrame(localRect);
    int i2 = paramInt2 - m;
    int i3;
    if (paramInt1 + n > localRect.right)
    {
      i3 = i1 + (paramInt1 - n);
      if (i2 + m > localRect.bottom)
        i2 = i2 - m - paramInt3;
    }
    while (true)
    {
      this.a.showAtLocation(paramView, 0, i3, i2);
      this.a.setOnDismissListener(new h(this));
      return;
      i3 = paramInt1 - i1;
      if (i2 + m <= localRect.bottom)
        continue;
      i2 = i2 - m - paramInt3;
    }
  }

  public void a(View paramView, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    b();
    View localView = this.e.inflate(2130903059, null, false);
    ViewGroup localViewGroup = (ViewGroup)localView.findViewById(2131558454);
    Iterator localIterator = this.c.iterator();
    int i = this.c.size();
    int j = 0;
    if (localIterator.hasNext())
    {
      as localas = (as)localIterator.next();
      Button localButton = (Button)this.e.inflate(2130903123, localViewGroup, false);
      localButton.setText(localas.b);
      localButton.setTag(localas);
      int i4 = 2130837767;
      if (j == 0)
      {
        i4 = 2130837766;
        if (i == 1)
          i4 = 2130837768;
      }
      while (true)
      {
        localButton.setBackgroundResource(i4);
        localButton.setOnClickListener(this);
        localViewGroup.addView(localButton);
        j++;
        break;
        if (j != i - 1)
          continue;
        i4 = 2130837765;
      }
    }
    this.a = new PopupWindow(localView, -2, -2);
    this.a.setBackgroundDrawable(new BitmapDrawable());
    this.a.setTouchable(true);
    this.a.setFocusable(true);
    this.a.setInputMethodMode(2);
    this.a.setOutsideTouchable(true);
    int k = paramView.getMeasuredWidth();
    int m = a(paramView, this.a, localView, k, 0);
    int n = localView.getMeasuredWidth();
    int i1 = c.a(this.b, 0.0F);
    Rect localRect = new Rect();
    paramView.getWindowVisibleDisplayFrame(localRect);
    int i2 = paramInt2 - m * 2;
    if (i2 < 0)
      i2 = paramInt3 - m;
    int i3;
    if (paramInt1 + n > localRect.right)
    {
      i3 = i1 + (paramInt1 - n);
      if (i2 + m > localRect.bottom)
        i2 = i2 - m - paramInt4;
    }
    while (true)
    {
      this.a.showAtLocation(paramView, 0, i3, i2);
      this.a.setOnDismissListener(new g(this));
      return;
      i3 = paramInt1 - i1;
      if (i2 + m <= localRect.bottom)
        continue;
      i2 = i2 - m - paramInt4;
    }
  }

  public void a(bz parambz)
  {
    this.d = parambz;
  }

  public void b()
  {
    if (this.a != null)
    {
      this.a.dismiss();
      this.a = null;
    }
  }

  public void onClick(View paramView)
  {
    b();
    if ((this.d != null) && (paramView != null))
    {
      as localas = (as)paramView.getTag();
      this.d.a(localas.a);
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.view.f
 * JD-Core Version:    0.6.0
 */